package com.atguigu.spzx.manner.controller;

import com.atguigu.spzx.manner.service.SysMenuService;
import com.atguigu.spzx.model.entity.SysMenu;
import com.atguigu.spzx.model.entity.SysRole;
import com.atguigu.spzx.model.myemun.ResultCodeEnum;
import com.atguigu.spzx.model.vo.common.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@RestController
@RequestMapping("/admin/system/sysMenu")
@CrossOrigin(allowCredentials = "true", originPatterns = "*", allowedHeaders = "*")
public class SysMenuController {
   @Autowired
    private SysMenuService sysMenuService;
    @GetMapping("/findNodes")
    public Result<List<SysMenu>> findNodes() {
       List<SysMenu>  sysMenu = sysMenuService.findNodes();
        return Result.build(sysMenu,ResultCodeEnum.SUCCESS);
    }
    @PostMapping("/save")
    public Result saveSysMenu(@RequestBody SysMenu sysMenu) {
       sysMenuService.save(sysMenu);
        return Result.build(ResultCodeEnum.SUCCESS);
    }
    @PutMapping("/updateSysMenu")
    public Result updateSysMenu(@RequestBody SysMenu sysMenu) {
        sysMenuService.updateSysMenu(sysMenu);
        return Result.build(ResultCodeEnum.SUCCESS);
    }
    @DeleteMapping("/deleteSysMenu/{id}")
    public Result delete(@PathVariable("id") Long id) {
        sysMenuService.delete(id);
        return Result.build(ResultCodeEnum.SUCCESS);
    }


}
